#version 450

layout(location = 0) in vec3 positionOS;
layout(location = 1) in vec3 normalOS;

layout(std140, binding = 0) uniform PerDraw
{
    mat4 viewMatrix;
    mat4 projMatrix;
};
layout(std140, binding = 2) uniform PerObject
{
    mat4 modelMatrix;
};

out Varyings
{
    vec3 normalCS;
} o;

void main()
{
    vec3 normalWS = mat3(transpose(inverse(viewMatrix * modelMatrix))) * normalOS;
    o.normalCS = normalize((projMatrix * vec4(normalWS, 0.0)).xyz);
    gl_Position = projMatrix * viewMatrix * modelMatrix * vec4(positionOS, 1.0);
}
